package com.iclub.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.iclub.dao.ActiveInfoDao;
import com.iclub.model.ActiveInfo;
import com.iclub.model.SignUpInfo;
import com.iclub.service.ActiveInfoService;
import com.iclub.util.Constants;

@Service
public class ActiveInfoServiceImpl extends BaseService implements ActiveInfoService {

	@Override
	public Map<String, Object> insertActiveInfo(ActiveInfo activeInfo) {
		Map<String,Object> res=new HashMap<String, Object>();
		try {
			activeInfoDao.insertActiveInfo(activeInfo);
			res.put(Constants.KEY_RESCODE, Constants.SUCCESS_RESCODE);
			res.put(Constants.KEY_RESMSG, Constants.SUCCESS_RESMSG);
		} catch (Exception e) {
			log_detail.error("插入用户动态信息,系统异常",e);
			res.put(Constants.KEY_RESCODE, Constants.FAIL_RESCODE);
			res.put(Constants.KEY_RESMSG, Constants.FAIL_RESMSG);
		}
		return res;
	}

	@Override
	public Map<String, Object> insertSignupInfo(SignUpInfo signUpInfo) {
		Map<String,Object> res=new HashMap<String, Object>();
		try {
			activeInfoDao.insertSignupInfo(signUpInfo);
			res.put(Constants.KEY_RESCODE, Constants.SUCCESS_RESCODE);
			res.put(Constants.KEY_RESMSG, Constants.SUCCESS_RESMSG);
		} catch (Exception e) {
			log_detail.error("插入报名信息(邀约、求约报名和说说评论),系统异常",e);
			res.put(Constants.KEY_RESCODE, Constants.FAIL_RESCODE);
			res.put(Constants.KEY_RESMSG, Constants.FAIL_RESMSG);
		}
		return res;
	}

	@Override
	public Map<String, Object> selectActiveInfo(int activeId) {
		Map<String,Object> res=new HashMap<String, Object>();
		ActiveInfo activeInfo=null;
		List<SignUpInfo> signUpInfolist=null;
		try {
			signUpInfolist= (List<SignUpInfo>) activeInfoDao.selectSignUpInfoList(activeId);
			if(signUpInfolist!=null){
				res.put(Constants.KEY_RESCONTENT, signUpInfolist);
			}
			activeInfo=activeInfoDao.selectActiveInfo(activeId);
			if(activeInfo!=null){
				res.put(Constants.KEY_RESCODE, Constants.SUCCESS_RESCODE);
				res.put(Constants.KEY_RESMSG, Constants.SUCCESS_RESMSG);
				//res.put("activeInfoDetail", activeInfo);
			}
			else{
				res.put(Constants.KEY_RESCODE, Constants.SUCCESS_RESCODE);
				res.put(Constants.KEY_RESMSG, Constants.NORESULT_RESMSG);
			}
		} catch (Exception e) {
			log_detail.error("查询动态信息详情,系统异常",e);
			res.put(Constants.KEY_RESCODE, Constants.FAIL_RESCODE);
			res.put(Constants.KEY_RESMSG, Constants.FAIL_RESMSG);
		}
		return res;
	}

	@Override
	public Map<String, Object> selectActiveInfoList(Map<String, Object> map) {
		Map<String,Object> res=new HashMap<String, Object>();
		List<ActiveInfo> activeInfolist=null;
		try {
			activeInfolist=(List<ActiveInfo>) activeInfoDao.selectActiveInfoList(map);
			if(activeInfolist!=null){
				res.put(Constants.KEY_RESCODE, Constants.SUCCESS_RESCODE);
				res.put(Constants.KEY_RESMSG, Constants.SUCCESS_RESMSG);
				res.put(Constants.KEY_RESCONTENT, activeInfolist);
			}
			else{
				res.put(Constants.KEY_RESCODE, Constants.SUCCESS_RESCODE);
				res.put(Constants.KEY_RESMSG, Constants.NORESULT_RESMSG);
			}
		} catch (Exception e) {
			log_detail.error("查询动态信息详情,系统异常",e);
			res.put(Constants.KEY_RESCODE, Constants.FAIL_RESCODE);
			res.put(Constants.KEY_RESMSG, Constants.FAIL_RESMSG);
		}
		return res;
	}

	@Override
	public Map<String, Object> selectSignUpInfoList(Map<String, String> map) {
		// TODO Auto-generated method stub
		return null;
	}

//	@SuppressWarnings("unchecked")
//	@Override
//	public Map<String, Object> selectSignUpInfoList(Map<String, String> map) {
//		Map<String,Object> res=new HashMap<String, Object>();
//		List<SignUpInfo> signUpInfolist=null;
//		try {
//			signUpInfolist= (List<SignUpInfo>) activeInfoDao.selectSignUpInfoList(map);
//			if(signUpInfolist!=null){
//				res.put(Constants.KEY_RESCODE, Constants.SUCCESS_RESCODE);
//				res.put(Constants.KEY_RESMSG, Constants.SUCCESS_RESMSG);
//				res.put(Constants.KEY_RESCONTENT, signUpInfolist);
//			}
//			else{
//				res.put(Constants.KEY_RESCODE, Constants.SUCCESS_RESCODE);
//				res.put(Constants.KEY_RESMSG, Constants.NORESULT_RESMSG);
//			}
//		} catch (Exception e) {
//			log_detail.error("查询报名信息详情,系统异常",e);
//			res.put(Constants.KEY_RESCODE, Constants.FAIL_RESCODE);
//			res.put(Constants.KEY_RESMSG, Constants.FAIL_RESMSG);
//		}
//		return res;
//	}
//	

}
